import { IsNotEmpty } from "class-validator";
import BaseEntity from "./BaseEntity";
import { ExtData, Photos } from "./CustomTransform";
import { Transform, Type } from "class-transformer";

export class JournalsEntity extends BaseEntity {
  @Type(() => Number)
  @IsNotEmpty()
  m_id: number;

  @IsNotEmpty()
  @Type(() => Number)
  u_id: number;

  @Type(() => Number)
  id: number;

  // 标题可以为空，内容不能。
  title: string;

  @IsNotEmpty()
  content: string;

  @Transform(Photos)
  photos: string | object;

  @Type(() => Number)
  is_open: boolean; // 1: 公开，0: 仅自己可见

  @Transform(ExtData)
  ext_data: string | object;
}
